<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qimagereader.cpp -->
  <title>QImageReader Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QImageReader</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#formats">Formats</a></li>
<li class="level2"><a href="#high-resolution-versions-of-images">High Resolution Versions of Images</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QImageReader Class</h1>
<!-- $$$QImageReader-brief -->
<p>The QImageReader class provides a format independent interface for reading images from files or other devices. <a href="#details">More...</a></p>
<!-- @@@QImageReader -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QImageReader&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr></table></div><ul>
<li><a href="qimagereader-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are <a href="../qtdoc/threads-reentrancy.html">reentrant</a>.</p>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#ImageReaderError-enum">ImageReaderError</a></b> { FileNotFoundError, DeviceError, UnsupportedFormatError, InvalidDataError, UnknownError }</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#QImageReader-2">QImageReader</a></b>(const QString &amp;<i>fileName</i>, const QByteArray &amp;<i>format</i> = QByteArray())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#QImageReader-1">QImageReader</a></b>(QIODevice *<i>device</i>, const QByteArray &amp;<i>format</i> = QByteArray())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#QImageReader">QImageReader</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#dtor.QImageReader">~QImageReader</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#autoDetectImageFormat">autoDetectImageFormat</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#autoTransform">autoTransform</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QColor </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#backgroundColor">backgroundColor</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#canRead">canRead</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#clipRect">clipRect</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#currentImageNumber">currentImageNumber</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#currentImageRect">currentImageRect</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#decideFormatFromContent">decideFormatFromContent</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QIODevice *</td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#device">device</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QImageReader::ImageReaderError </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#error">error</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#errorString">errorString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#fileName">fileName</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#format">format</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#gamma">gamma</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#imageCount">imageCount</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QImage::Format </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#imageFormat">imageFormat</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#jumpToImage">jumpToImage</a></b>(int <i>imageNumber</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#jumpToNextImage">jumpToNextImage</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#loopCount">loopCount</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#nextImageDelay">nextImageDelay</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#quality">quality</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QImage </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#read">read</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#read-1">read</a></b>(QImage *<i>image</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#scaledClipRect">scaledClipRect</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#scaledSize">scaledSize</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setAutoDetectImageFormat">setAutoDetectImageFormat</a></b>(bool <i>enabled</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setAutoTransform">setAutoTransform</a></b>(bool <i>enabled</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setBackgroundColor">setBackgroundColor</a></b>(const QColor &amp;<i>color</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setClipRect">setClipRect</a></b>(const QRect &amp;<i>rect</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setDecideFormatFromContent">setDecideFormatFromContent</a></b>(bool <i>ignored</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setDevice">setDevice</a></b>(QIODevice *<i>device</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setFileName">setFileName</a></b>(const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setFormat">setFormat</a></b>(const QByteArray &amp;<i>format</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setGamma">setGamma</a></b>(float <i>gamma</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setQuality">setQuality</a></b>(int <i>quality</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setScaledClipRect">setScaledClipRect</a></b>(const QRect &amp;<i>rect</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#setScaledSize">setScaledSize</a></b>(const QSize &amp;<i>size</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#size">size</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#subType">subType</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#supportedSubTypes">supportedSubTypes</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#supportsAnimation">supportsAnimation</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#supportsOption">supportsOption</a></b>(QImageIOHandler::ImageOption <i>option</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#text">text</a></b>(const QString &amp;<i>key</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#textKeys">textKeys</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QImageIOHandler::Transformations </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#transformation">transformation</a></b>() const</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#imageFormat-1">imageFormat</a></b>(const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#imageFormat-2">imageFormat</a></b>(QIODevice *<i>device</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#imageFormatsForMimeType">imageFormatsForMimeType</a></b>(const QByteArray &amp;<i>mimeType</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qimagereader.html#supportedMimeTypes">supportedMimeTypes</a></b>()</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QImageReader-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The most common way to read images is through <a href="qimage.html">QImage</a> and <a href="qpixmap.html">QPixmap</a>'s constructors, or by calling <a href="qimage.html#load">QImage::load</a>() and <a href="qpixmap.html#load">QPixmap::load</a>(). QImageReader is a specialized class which gives you more control when reading images. For example, you can read an image into a specific size by calling <a href="qimagereader.html#setScaledSize">setScaledSize</a>(), and you can select a clip rect, effectively loading only parts of an image, by calling <a href="qimagereader.html#setClipRect">setClipRect</a>(). Depending on the underlying support in the image format, this can save memory and speed up loading of images.</p>
<p>To read an image, you start by constructing a QImageReader object. Pass either a file name or a device pointer, and the image format to QImageReader's constructor. You can then set several options, such as the clip rect (by calling <a href="qimagereader.html#setClipRect">setClipRect</a>()) and scaled size (by calling <a href="qimagereader.html#setScaledSize">setScaledSize</a>()). <a href="qimagereader.html#canRead">canRead</a>() returns the image if the QImageReader can read the image (i.e&#x2e;, the image format is supported and the device is open for reading). Call <a href="qimagereader.html#read">read</a>() to read the image.</p>
<p>If any error occurs when reading the image, <a href="qimagereader.html#read">read</a>() will return a null <a href="qimage.html">QImage</a>. You can then call <a href="qimagereader.html#error">error</a>() to find the type of error that occurred, or <a href="qimagereader.html#errorString">errorString</a>() to get a human readable description of what went wrong.</p>
<p><b>Note: </b>QImageReader assumes exclusive control over the file or device that is assigned. Any attempts to modify the assigned file or device during the lifetime of the QImageReader object will yield undefined results.</p><a name="formats"></a>
<h3 id="formats">Formats</h3>
<p>Call <a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>() for a list of formats that QImageReader can read. QImageReader supports all built-in image formats, in addition to any image format plugins that support reading. Call <a href="qimagereader.html#supportedMimeTypes">supportedMimeTypes</a>() to obtain a list of supported MIME types, which for example can be passed to <a href="../qtwidgets/qfiledialog.html#setMimeTypeFilters">QFileDialog::setMimeTypeFilters</a>().</p>
<p>QImageReader autodetects the image format by default, by looking at the provided (optional) format string, the file name suffix, and the data stream contents. You can enable or disable this feature, by calling <a href="qimagereader.html#setAutoDetectImageFormat">setAutoDetectImageFormat</a>().</p>
<a name="high-resolution-versions-of-images"></a>
<h3 id="high-resolution-versions-of-images">High Resolution Versions of Images</h3>
<p>It is possible to provide high resolution versions of images should a scaling between <i>device pixels</i> and <i>device independent pixels</i> be in effect.</p>
<p>The high resolution version is marked by the suffix <code>@2x</code> on the base name. The image read will have its <i>device pixel ratio</i> set to a value of 2.</p>
<p>This can be disabled by setting the environment variable <code>QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING</code>.</p>
</div>
<p><b>See also </b><a href="qimagewriter.html">QImageWriter</a>, <a href="qimageiohandler.html">QImageIOHandler</a>, <a href="qimageioplugin.html">QImageIOPlugin</a>, <a href="../qtcore/qmimedatabase.html">QMimeDatabase</a>, <a href="qimage.html#devicePixelRatio">QImage::devicePixelRatio</a>(), <a href="qpixmap.html#devicePixelRatio">QPixmap::devicePixelRatio</a>(), <a href="qicon.html">QIcon</a>, <a href="qpainter.html#drawPixmap">QPainter::drawPixmap</a>(), <a href="qpainter.html#drawImage">QPainter::drawImage</a>(), and <a href="../qtcore/qt.html#ApplicationAttribute-enum">Qt::AA_UseHighDpiPixmaps</a>.</p>
<!-- @@@QImageReader -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ImageReaderError$$$UnknownError$$$FileNotFoundError$$$DeviceError$$$UnsupportedFormatError$$$InvalidDataError -->
<h3 class="fn" id="ImageReaderError-enum"><a name="ImageReaderError-enum"></a>enum QImageReader::<span class="name">ImageReaderError</span></h3>
<p>This enum describes the different types of errors that can occur when reading images with <a href="qimagereader.html">QImageReader</a>.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QImageReader::FileNotFoundError</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign"><a href="qimagereader.html">QImageReader</a> was used with a file name, but not file was found with that name. This can also happen if the file name contained no extension, and the file with the correct extension is not supported by Qt.</td></tr>
<tr><td class="topAlign"><code>QImageReader::DeviceError</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign"><a href="qimagereader.html">QImageReader</a> encountered a device error when reading the image. You can consult your particular device for more details on what went wrong.</td></tr>
<tr><td class="topAlign"><code>QImageReader::UnsupportedFormatError</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">Qt does not support the requested image format.</td></tr>
<tr><td class="topAlign"><code>QImageReader::InvalidDataError</code></td><td class="topAlign tblval"><code>4</code></td><td class="topAlign">The image data was invalid, and <a href="qimagereader.html">QImageReader</a> was unable to read an image from it. The can happen if the image file is damaged.</td></tr>
<tr><td class="topAlign"><code>QImageReader::UnknownError</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">An unknown error occurred. If you get this value after calling <a href="qimagereader.html#read">read</a>(), it is most likely caused by a bug in <a href="qimagereader.html">QImageReader</a>.</td></tr>
</table></div>
<!-- @@@ImageReaderError -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QImageReader$$$QImageReaderconstQString&constQByteArray& -->
<h3 class="fn" id="QImageReader-2"><a name="QImageReader-2"></a>QImageReader::<span class="name">QImageReader</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>fileName</i>, const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<i>format</i> = QByteArray())</h3>
<p>Constructs a QImageReader object with the file name <i>fileName</i> and the image format <i>format</i>.</p>
<p><b>See also </b><a href="qimagereader.html#setFileName">setFileName</a>().</p>
<!-- @@@QImageReader -->
<!-- $$$QImageReader$$$QImageReaderQIODevice*constQByteArray& -->
<h3 class="fn" id="QImageReader-1"><a name="QImageReader-1"></a>QImageReader::<span class="name">QImageReader</span>(<span class="type"><a href="../qtcore/qiodevice.html">QIODevice</a></span> *<i>device</i>, const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<i>format</i> = QByteArray())</h3>
<p>Constructs a QImageReader object with the device <i>device</i> and the image format <i>format</i>.</p>
<!-- @@@QImageReader -->
<!-- $$$QImageReader[overload1]$$$QImageReader -->
<h3 class="fn" id="QImageReader"><a name="QImageReader"></a>QImageReader::<span class="name">QImageReader</span>()</h3>
<p>Constructs an empty QImageReader object. Before reading an image, call <a href="qimagereader.html#setDevice">setDevice</a>() or <a href="qimagereader.html#setFileName">setFileName</a>().</p>
<!-- @@@QImageReader -->
<!-- $$$~QImageReader[overload1]$$$~QImageReader -->
<h3 class="fn" id="dtor.QImageReader"><a name="dtor.QImageReader"></a>QImageReader::<span class="name">~QImageReader</span>()</h3>
<p>Destructs the <a href="qimagereader.html">QImageReader</a> object.</p>
<!-- @@@~QImageReader -->
<!-- $$$autoDetectImageFormat[overload1]$$$autoDetectImageFormat -->
<h3 class="fn" id="autoDetectImageFormat"><a name="autoDetectImageFormat"></a><span class="type">bool</span> QImageReader::<span class="name">autoDetectImageFormat</span>() const</h3>
<p>Returns <code>true</code> if image format autodetection is enabled on this image reader; otherwise returns <code>false</code>. By default, autodetection is enabled.</p>
<p><b>See also </b><a href="qimagereader.html#setAutoDetectImageFormat">setAutoDetectImageFormat</a>().</p>
<!-- @@@autoDetectImageFormat -->
<!-- $$$autoTransform[overload1]$$$autoTransform -->
<h3 class="fn" id="autoTransform"><a name="autoTransform"></a><span class="type">bool</span> QImageReader::<span class="name">autoTransform</span>() const</h3>
<p>Returns <code>true</code> if the image handler will apply transformation metadata on <a href="qimagereader.html#read">read</a>().</p>
<p>This function was introduced in Qt 5.5.</p>
<p><b>See also </b><a href="qimagereader.html#setAutoTransform">setAutoTransform</a>(), <a href="qimagereader.html#transformation">transformation</a>(), and <a href="qimagereader.html#read">read</a>().</p>
<!-- @@@autoTransform -->
<!-- $$$backgroundColor[overload1]$$$backgroundColor -->
<h3 class="fn" id="backgroundColor"><a name="backgroundColor"></a><span class="type"><a href="qcolor.html">QColor</a></span> QImageReader::<span class="name">backgroundColor</span>() const</h3>
<p>Returns the background color that's used when reading an image. If the image format does not support setting the background color an invalid color is returned.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qimagereader.html#setBackgroundColor">setBackgroundColor</a>() and <a href="qimagereader.html#read">read</a>().</p>
<!-- @@@backgroundColor -->
<!-- $$$canRead[overload1]$$$canRead -->
<h3 class="fn" id="canRead"><a name="canRead"></a><span class="type">bool</span> QImageReader::<span class="name">canRead</span>() const</h3>
<p>Returns <code>true</code> if an image can be read for the device (i.e&#x2e;, the image format is supported, and the device seems to contain valid data); otherwise returns <code>false</code>.</p>
<p>canRead() is a lightweight function that only does a quick test to see if the image data is valid. <a href="qimagereader.html#read">read</a>() may still return false after canRead() returns <code>true</code>, if the image data is corrupt.</p>
<p><b>Note: </b>A <a href="../qtcore/qmimedatabase.html">QMimeDatabase</a> lookup is normally a better approach than this function for identifying potentially non-image files or data.</p><p>For images that support animation, canRead() returns <code>false</code> when all frames have been read.</p>
<p><b>See also </b><a href="qimagereader.html#read">read</a>(), <a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>(), and <a href="../qtcore/qmimedatabase.html">QMimeDatabase</a>.</p>
<!-- @@@canRead -->
<!-- $$$clipRect[overload1]$$$clipRect -->
<h3 class="fn" id="clipRect"><a name="clipRect"></a><span class="type"><a href="../qtcore/qrect.html">QRect</a></span> QImageReader::<span class="name">clipRect</span>() const</h3>
<p>Returns the clip rect (also known as the ROI, or Region Of Interest) of the image. If no clip rect has been set, an invalid <a href="../qtcore/qrect.html">QRect</a> is returned.</p>
<p><b>See also </b><a href="qimagereader.html#setClipRect">setClipRect</a>().</p>
<!-- @@@clipRect -->
<!-- $$$currentImageNumber[overload1]$$$currentImageNumber -->
<h3 class="fn" id="currentImageNumber"><a name="currentImageNumber"></a><span class="type">int</span> QImageReader::<span class="name">currentImageNumber</span>() const</h3>
<p>For image formats that support animation, this function returns the sequence number of the current frame. If the image format doesn't support animation, 0 is returned.</p>
<p>This function returns -1 if an error occurred.</p>
<p><b>See also </b><a href="qimagereader.html#supportsAnimation">supportsAnimation</a>(), <a href="qimageiohandler.html#currentImageNumber">QImageIOHandler::currentImageNumber</a>(), and <a href="qimagereader.html#canRead">canRead</a>().</p>
<!-- @@@currentImageNumber -->
<!-- $$$currentImageRect[overload1]$$$currentImageRect -->
<h3 class="fn" id="currentImageRect"><a name="currentImageRect"></a><span class="type"><a href="../qtcore/qrect.html">QRect</a></span> QImageReader::<span class="name">currentImageRect</span>() const</h3>
<p>For image formats that support animation, this function returns the rect for the current frame. Otherwise, a null rect is returned.</p>
<p><b>See also </b><a href="qimagereader.html#supportsAnimation">supportsAnimation</a>() and <a href="qimageiohandler.html#currentImageRect">QImageIOHandler::currentImageRect</a>().</p>
<!-- @@@currentImageRect -->
<!-- $$$decideFormatFromContent[overload1]$$$decideFormatFromContent -->
<h3 class="fn" id="decideFormatFromContent"><a name="decideFormatFromContent"></a><span class="type">bool</span> QImageReader::<span class="name">decideFormatFromContent</span>() const</h3>
<p>Returns whether the image reader should decide which plugin to use only based on the contents of the datastream rather than on the file extension.</p>
<p><b>See also </b><a href="qimagereader.html#setDecideFormatFromContent">setDecideFormatFromContent</a>().</p>
<!-- @@@decideFormatFromContent -->
<!-- $$$device[overload1]$$$device -->
<h3 class="fn" id="device"><a name="device"></a><span class="type"><a href="../qtcore/qiodevice.html">QIODevice</a></span> *QImageReader::<span class="name">device</span>() const</h3>
<p>Returns the device currently assigned to <a href="qimagereader.html">QImageReader</a>, or <code>nullptr</code> if no device has been assigned.</p>
<p><b>See also </b><a href="qimagereader.html#setDevice">setDevice</a>().</p>
<!-- @@@device -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn" id="error"><a name="error"></a><span class="type"><a href="qimagereader.html#ImageReaderError-enum">QImageReader::ImageReaderError</a></span> QImageReader::<span class="name">error</span>() const</h3>
<p>Returns the type of error that occurred last.</p>
<p><b>See also </b><a href="qimagereader.html#ImageReaderError-enum">ImageReaderError</a> and <a href="qimagereader.html#errorString">errorString</a>().</p>
<!-- @@@error -->
<!-- $$$errorString[overload1]$$$errorString -->
<h3 class="fn" id="errorString"><a name="errorString"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QImageReader::<span class="name">errorString</span>() const</h3>
<p>Returns a human readable description of the last error that occurred.</p>
<p><b>See also </b><a href="qimagereader.html#error">error</a>().</p>
<!-- @@@errorString -->
<!-- $$$fileName[overload1]$$$fileName -->
<h3 class="fn" id="fileName"><a name="fileName"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QImageReader::<span class="name">fileName</span>() const</h3>
<p>If the currently assigned device is a <a href="../qtcore/qfile.html">QFile</a>, or if <a href="qimagereader.html#setFileName">setFileName</a>() has been called, this function returns the name of the file <a href="qimagereader.html">QImageReader</a> reads from. Otherwise (i.e&#x2e;, if no device has been assigned or the device is not a <a href="../qtcore/qfile.html">QFile</a>), an empty <a href="../qtcore/qstring.html">QString</a> is returned.</p>
<p><b>See also </b><a href="qimagereader.html#setFileName">setFileName</a>() and <a href="qimagereader.html#setDevice">setDevice</a>().</p>
<!-- @@@fileName -->
<!-- $$$format[overload1]$$$format -->
<h3 class="fn" id="format"><a name="format"></a><span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> QImageReader::<span class="name">format</span>() const</h3>
<p>Returns the format <a href="qimagereader.html">QImageReader</a> uses for reading images.</p>
<p>You can call this function after assigning a device to the reader to determine the format of the device. For example:</p>
<pre class="cpp">

  <span class="type"><a href="qimagereader.html#QImageReader">QImageReader</a></span> reader(<span class="string">&quot;image.png&quot;</span>);
  <span class="comment">// reader.format() == &quot;png&quot;</span>

</pre>
<p>If the reader cannot read any image from the device (e.g&#x2e;, there is no image there, or the image has already been read), or if the format is unsupported, this function returns an empty QByteArray().</p>
<p><b>See also </b><a href="qimagereader.html#setFormat">setFormat</a>() and <a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>().</p>
<!-- @@@format -->
<!-- $$$gamma[overload1]$$$gamma -->
<h3 class="fn" id="gamma"><a name="gamma"></a><span class="type">float</span> QImageReader::<span class="name">gamma</span>() const</h3>
<p>Returns the gamma level of the decoded image. If <a href="qimagereader.html#setGamma">setGamma</a>() has been called and gamma correction is supported it will return the gamma set. If gamma level is not supported by the image format, <code>0.0</code> is returned.</p>
<p>This function was introduced in Qt 5.6.</p>
<p><b>See also </b><a href="qimagereader.html#setGamma">setGamma</a>().</p>
<!-- @@@gamma -->
<!-- $$$imageCount[overload1]$$$imageCount -->
<h3 class="fn" id="imageCount"><a name="imageCount"></a><span class="type">int</span> QImageReader::<span class="name">imageCount</span>() const</h3>
<p>For image formats that support animation, this function returns the total number of images in the animation. If the format does not support animation, 0 is returned.</p>
<p>This function returns -1 if an error occurred.</p>
<p><b>See also </b><a href="qimagereader.html#supportsAnimation">supportsAnimation</a>(), <a href="qimageiohandler.html#imageCount">QImageIOHandler::imageCount</a>(), and <a href="qimagereader.html#canRead">canRead</a>().</p>
<!-- @@@imageCount -->
<!-- $$$imageFormat[overload1]$$$imageFormat -->
<h3 class="fn" id="imageFormat"><a name="imageFormat"></a><span class="type"><a href="qimage.html#Format-enum">QImage::Format</a></span> QImageReader::<span class="name">imageFormat</span>() const</h3>
<p>Returns the format of the image, without actually reading the image contents. The format describes the image format <a href="qimagereader.html#read">QImageReader::read</a>() returns, not the format of the actual image.</p>
<p>If the image format does not support this feature, this function returns an invalid format.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also </b><a href="qimageiohandler.html#ImageOption-enum">QImageIOHandler::ImageOption</a>, <a href="qimageiohandler.html#option">QImageIOHandler::option</a>(), and <a href="qimageiohandler.html#supportsOption">QImageIOHandler::supportsOption</a>().</p>
<!-- @@@imageFormat -->
<!-- $$$imageFormat$$$imageFormatconstQString& -->
<h3 class="fn" id="imageFormat-1"><a name="imageFormat-1"></a><code>[static] </code><span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> QImageReader::<span class="name">imageFormat</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>If supported, this function returns the image format of the file <i>fileName</i>. Otherwise, an empty string is returned.</p>
<!-- @@@imageFormat -->
<!-- $$$imageFormat$$$imageFormatQIODevice* -->
<h3 class="fn" id="imageFormat-2"><a name="imageFormat-2"></a><code>[static] </code><span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> QImageReader::<span class="name">imageFormat</span>(<span class="type"><a href="../qtcore/qiodevice.html">QIODevice</a></span> *<i>device</i>)</h3>
<p>If supported, this function returns the image format of the device <i>device</i>. Otherwise, an empty string is returned.</p>
<p><b>See also </b><a href="qimagereader.html#autoDetectImageFormat">QImageReader::autoDetectImageFormat</a>().</p>
<!-- @@@imageFormat -->
<!-- $$$imageFormatsForMimeType[overload1]$$$imageFormatsForMimeTypeconstQByteArray& -->
<h3 class="fn" id="imageFormatsForMimeType"><a name="imageFormatsForMimeType"></a><code>[static] </code><span class="type">QList</span>&lt;<span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span>&gt; QImageReader::<span class="name">imageFormatsForMimeType</span>(const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<i>mimeType</i>)</h3>
<p>Returns the list of image formats corresponding to <i>mimeType</i>.</p>
<p>Note that the <a href="qguiapplication.html">QGuiApplication</a> instance must be created before this function is called.</p>
<p>This function was introduced in Qt 5.12.</p>
<p><b>See also </b><a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>() and <a href="qimagereader.html#supportedMimeTypes">supportedMimeTypes</a>().</p>
<!-- @@@imageFormatsForMimeType -->
<!-- $$$jumpToImage[overload1]$$$jumpToImageint -->
<h3 class="fn" id="jumpToImage"><a name="jumpToImage"></a><span class="type">bool</span> QImageReader::<span class="name">jumpToImage</span>(<span class="type">int</span> <i>imageNumber</i>)</h3>
<p>For image formats that support animation, this function skips to the image whose sequence number is <i>imageNumber</i>, returning true if successful or false if the corresponding image cannot be found.</p>
<p>The next call to <a href="qimagereader.html#read">read</a>() will attempt to read this image.</p>
<p><b>See also </b><a href="qimagereader.html#jumpToNextImage">jumpToNextImage</a>() and <a href="qimageiohandler.html#jumpToImage">QImageIOHandler::jumpToImage</a>().</p>
<!-- @@@jumpToImage -->
<!-- $$$jumpToNextImage[overload1]$$$jumpToNextImage -->
<h3 class="fn" id="jumpToNextImage"><a name="jumpToNextImage"></a><span class="type">bool</span> QImageReader::<span class="name">jumpToNextImage</span>()</h3>
<p>For image formats that support animation, this function steps over the current image, returning true if successful or false if there is no following image in the animation.</p>
<p>The default implementation calls <a href="qimagereader.html#read">read</a>(), then discards the resulting image, but the image handler may have a more efficient way of implementing this operation.</p>
<p><b>See also </b><a href="qimagereader.html#jumpToImage">jumpToImage</a>() and <a href="qimageiohandler.html#jumpToNextImage">QImageIOHandler::jumpToNextImage</a>().</p>
<!-- @@@jumpToNextImage -->
<!-- $$$loopCount[overload1]$$$loopCount -->
<h3 class="fn" id="loopCount"><a name="loopCount"></a><span class="type">int</span> QImageReader::<span class="name">loopCount</span>() const</h3>
<p>For image formats that support animation, this function returns the number of times the animation should loop. If this function returns -1, it can either mean the animation should loop forever, or that an error occurred. If an error occurred, <a href="qimagereader.html#canRead">canRead</a>() will return false.</p>
<p><b>See also </b><a href="qimagereader.html#supportsAnimation">supportsAnimation</a>(), <a href="qimageiohandler.html#loopCount">QImageIOHandler::loopCount</a>(), and <a href="qimagereader.html#canRead">canRead</a>().</p>
<!-- @@@loopCount -->
<!-- $$$nextImageDelay[overload1]$$$nextImageDelay -->
<h3 class="fn" id="nextImageDelay"><a name="nextImageDelay"></a><span class="type">int</span> QImageReader::<span class="name">nextImageDelay</span>() const</h3>
<p>For image formats that support animation, this function returns the number of milliseconds to wait until displaying the next frame in the animation. If the image format doesn't support animation, 0 is returned.</p>
<p>This function returns -1 if an error occurred.</p>
<p><b>See also </b><a href="qimagereader.html#supportsAnimation">supportsAnimation</a>(), <a href="qimageiohandler.html#nextImageDelay">QImageIOHandler::nextImageDelay</a>(), and <a href="qimagereader.html#canRead">canRead</a>().</p>
<!-- @@@nextImageDelay -->
<!-- $$$quality[overload1]$$$quality -->
<h3 class="fn" id="quality"><a name="quality"></a><span class="type">int</span> QImageReader::<span class="name">quality</span>() const</h3>
<p>Returns the quality setting of the image format.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qimagereader.html#setQuality">setQuality</a>().</p>
<!-- @@@quality -->
<!-- $$$read[overload1]$$$read -->
<h3 class="fn" id="read"><a name="read"></a><span class="type"><a href="qimage.html">QImage</a></span> QImageReader::<span class="name">read</span>()</h3>
<p>Reads an image from the device. On success, the image that was read is returned; otherwise, a null <a href="qimage.html">QImage</a> is returned. You can then call <a href="qimagereader.html#error">error</a>() to find the type of error that occurred, or <a href="qimagereader.html#errorString">errorString</a>() to get a human readable description of the error.</p>
<p>For image formats that support animation, calling read() repeatedly will return the next frame. When all frames have been read, a null image will be returned.</p>
<p><b>See also </b><a href="qimagereader.html#canRead">canRead</a>(), <a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>(), <a href="qimagereader.html#supportsAnimation">supportsAnimation</a>(), and <a href="qmovie.html">QMovie</a>.</p>
<!-- @@@read -->
<!-- $$$read$$$readQImage* -->
<h3 class="fn" id="read-1"><a name="read-1"></a><span class="type">bool</span> QImageReader::<span class="name">read</span>(<span class="type"><a href="qimage.html">QImage</a></span> *<i>image</i>)</h3>
<p>This is an overloaded function.</p>
<p>Reads an image from the device into <i>image</i>, which must point to a <a href="qimage.html">QImage</a>. Returns <code>true</code> on success; otherwise, returns <code>false</code>.</p>
<p>If <i>image</i> has same format and size as the image data that is about to be read, this function may not need to allocate a new image before reading. Because of this, it can be faster than the other read() overload, which always constructs a new image; especially when reading several images with the same format and size.</p>
<pre class="cpp">

  <span class="type"><a href="qimage.html">QImage</a></span> icon(<span class="number">64</span><span class="operator">,</span> <span class="number">64</span><span class="operator">,</span> <span class="type"><a href="qimage.html">QImage</a></span><span class="operator">::</span>Format_RGB32);
  <span class="type"><a href="qimagereader.html#QImageReader">QImageReader</a></span> reader(<span class="string">&quot;icon_64x64.bmp&quot;</span>);
  <span class="keyword">if</span> (reader<span class="operator">.</span>read(<span class="operator">&amp;</span>icon)) {
      <span class="comment">// Display icon</span>
  }

</pre>
<p>For image formats that support animation, calling read() repeatedly will return the next frame. When all frames have been read, a null image will be returned.</p>
<p><b>See also </b><a href="qimagereader.html#canRead">canRead</a>(), <a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>(), <a href="qimagereader.html#supportsAnimation">supportsAnimation</a>(), and <a href="qmovie.html">QMovie</a>.</p>
<!-- @@@read -->
<!-- $$$scaledClipRect[overload1]$$$scaledClipRect -->
<h3 class="fn" id="scaledClipRect"><a name="scaledClipRect"></a><span class="type"><a href="../qtcore/qrect.html">QRect</a></span> QImageReader::<span class="name">scaledClipRect</span>() const</h3>
<p>Returns the scaled clip rect of the image.</p>
<p><b>See also </b><a href="qimagereader.html#setScaledClipRect">setScaledClipRect</a>().</p>
<!-- @@@scaledClipRect -->
<!-- $$$scaledSize[overload1]$$$scaledSize -->
<h3 class="fn" id="scaledSize"><a name="scaledSize"></a><span class="type"><a href="../qtcore/qsize.html">QSize</a></span> QImageReader::<span class="name">scaledSize</span>() const</h3>
<p>Returns the scaled size of the image.</p>
<p><b>See also </b><a href="qimagereader.html#setScaledSize">setScaledSize</a>().</p>
<!-- @@@scaledSize -->
<!-- $$$setAutoDetectImageFormat[overload1]$$$setAutoDetectImageFormatbool -->
<h3 class="fn" id="setAutoDetectImageFormat"><a name="setAutoDetectImageFormat"></a><span class="type">void</span> QImageReader::<span class="name">setAutoDetectImageFormat</span>(<span class="type">bool</span> <i>enabled</i>)</h3>
<p>If <i>enabled</i> is true, image format autodetection is enabled; otherwise, it is disabled. By default, autodetection is enabled.</p>
<p><a href="qimagereader.html">QImageReader</a> uses an extensive approach to detecting the image format; firstly, if you pass a file name to <a href="qimagereader.html">QImageReader</a>, it will attempt to detect the file extension if the given file name does not point to an existing file, by appending supported default extensions to the given file name, one at a time. It then uses the following approach to detect the image format:</p>
<ul>
<li>Image plugins are queried first, based on either the optional format string, or the file name suffix (if the source device is a file). No content detection is done at this stage. <a href="qimagereader.html">QImageReader</a> will choose the first plugin that supports reading for this format.</li>
<li>If no plugin supports the image format, Qt's built-in handlers are checked based on either the optional format string, or the file name suffix.</li>
<li>If no capable plugins or built-in handlers are found, each plugin is tested by inspecting the content of the data stream.</li>
<li>If no plugins could detect the image format based on data contents, each built-in image handler is tested by inspecting the contents.</li>
<li>Finally, if all above approaches fail, <a href="qimagereader.html">QImageReader</a> will report failure when trying to read the image.</li>
</ul>
<p>By disabling image format autodetection, <a href="qimagereader.html">QImageReader</a> will only query the plugins and built-in handlers based on the format string (i.e&#x2e;, no file name extensions are tested).</p>
<p><b>See also </b><a href="qimagereader.html#autoDetectImageFormat">autoDetectImageFormat</a>(), <a href="qimageiohandler.html#canRead">QImageIOHandler::canRead</a>(), and <a href="qimageioplugin.html#capabilities">QImageIOPlugin::capabilities</a>().</p>
<!-- @@@setAutoDetectImageFormat -->
<!-- $$$setAutoTransform[overload1]$$$setAutoTransformbool -->
<h3 class="fn" id="setAutoTransform"><a name="setAutoTransform"></a><span class="type">void</span> QImageReader::<span class="name">setAutoTransform</span>(<span class="type">bool</span> <i>enabled</i>)</h3>
<p>Determines that images returned by <a href="qimagereader.html#read">read</a>() should have transformation metadata automatically applied if <i>enabled</i> is <code>true</code>.</p>
<p>This function was introduced in Qt 5.5.</p>
<p><b>See also </b><a href="qimagereader.html#autoTransform">autoTransform</a>(), <a href="qimagereader.html#transformation">transformation</a>(), and <a href="qimagereader.html#read">read</a>().</p>
<!-- @@@setAutoTransform -->
<!-- $$$setBackgroundColor[overload1]$$$setBackgroundColorconstQColor& -->
<h3 class="fn" id="setBackgroundColor"><a name="setBackgroundColor"></a><span class="type">void</span> QImageReader::<span class="name">setBackgroundColor</span>(const <span class="type"><a href="qcolor.html">QColor</a></span> &amp;<i>color</i>)</h3>
<p>Sets the background color to <i>color</i>. Image formats that support this operation are expected to initialize the background to <i>color</i> before reading an image.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qimagereader.html#backgroundColor">backgroundColor</a>() and <a href="qimagereader.html#read">read</a>().</p>
<!-- @@@setBackgroundColor -->
<!-- $$$setClipRect[overload1]$$$setClipRectconstQRect& -->
<h3 class="fn" id="setClipRect"><a name="setClipRect"></a><span class="type">void</span> QImageReader::<span class="name">setClipRect</span>(const <span class="type"><a href="../qtcore/qrect.html">QRect</a></span> &amp;<i>rect</i>)</h3>
<p>Sets the image clip rect (also known as the ROI, or Region Of Interest) to <i>rect</i>. The coordinates of <i>rect</i> are relative to the untransformed image size, as returned by <a href="qimagereader.html#size">size</a>().</p>
<p><b>See also </b><a href="qimagereader.html#clipRect">clipRect</a>(), <a href="qimagereader.html#setScaledSize">setScaledSize</a>(), and <a href="qimagereader.html#setScaledClipRect">setScaledClipRect</a>().</p>
<!-- @@@setClipRect -->
<!-- $$$setDecideFormatFromContent[overload1]$$$setDecideFormatFromContentbool -->
<h3 class="fn" id="setDecideFormatFromContent"><a name="setDecideFormatFromContent"></a><span class="type">void</span> QImageReader::<span class="name">setDecideFormatFromContent</span>(<span class="type">bool</span> <i>ignored</i>)</h3>
<p>If <i>ignored</i> is set to true, then the image reader will ignore specified formats or file extensions and decide which plugin to use only based on the contents in the datastream.</p>
<p>Setting this flag means that all image plugins gets loaded. Each plugin will read the first bytes in the image data and decide if the plugin is compatible or not.</p>
<p>This also disables auto detecting the image format.</p>
<p><b>See also </b><a href="qimagereader.html#decideFormatFromContent">decideFormatFromContent</a>().</p>
<!-- @@@setDecideFormatFromContent -->
<!-- $$$setDevice[overload1]$$$setDeviceQIODevice* -->
<h3 class="fn" id="setDevice"><a name="setDevice"></a><span class="type">void</span> QImageReader::<span class="name">setDevice</span>(<span class="type"><a href="../qtcore/qiodevice.html">QIODevice</a></span> *<i>device</i>)</h3>
<p>Sets <a href="qimagereader.html">QImageReader</a>'s device to <i>device</i>. If a device has already been set, the old device is removed from <a href="qimagereader.html">QImageReader</a> and is otherwise left unchanged.</p>
<p>If the device is not already open, <a href="qimagereader.html">QImageReader</a> will attempt to open the device in <a href="../qtcore/qiodevice.html#OpenModeFlag-enum">QIODevice::ReadOnly</a> mode by calling open(). Note that this does not work for certain devices, such as <a href="../qtcore/qprocess.html">QProcess</a>, <a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a> and <a href="../qtnetwork/qudpsocket.html">QUdpSocket</a>, where more logic is required to open the device.</p>
<p><b>See also </b><a href="qimagereader.html#device">device</a>() and <a href="qimagereader.html#setFileName">setFileName</a>().</p>
<!-- @@@setDevice -->
<!-- $$$setFileName[overload1]$$$setFileNameconstQString& -->
<h3 class="fn" id="setFileName"><a name="setFileName"></a><span class="type">void</span> QImageReader::<span class="name">setFileName</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>Sets the file name of <a href="qimagereader.html">QImageReader</a> to <i>fileName</i>. Internally, <a href="qimagereader.html">QImageReader</a> will create a <a href="../qtcore/qfile.html">QFile</a> object and open it in <a href="../qtcore/qiodevice.html#OpenModeFlag-enum">QIODevice::ReadOnly</a> mode, and use this when reading images.</p>
<p>If <i>fileName</i> does not include a file extension (e.g&#x2e;, .png or .bmp), <a href="qimagereader.html">QImageReader</a> will cycle through all supported extensions until it finds a matching file.</p>
<p><b>See also </b><a href="qimagereader.html#fileName">fileName</a>(), <a href="qimagereader.html#setDevice">setDevice</a>(), and <a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>().</p>
<!-- @@@setFileName -->
<!-- $$$setFormat[overload1]$$$setFormatconstQByteArray& -->
<h3 class="fn" id="setFormat"><a name="setFormat"></a><span class="type">void</span> QImageReader::<span class="name">setFormat</span>(const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<i>format</i>)</h3>
<p>Sets the format <a href="qimagereader.html">QImageReader</a> will use when reading images, to <i>format</i>. <i>format</i> is a case insensitive text string. Example:</p>
<pre class="cpp">

  <span class="type"><a href="qimagereader.html#QImageReader">QImageReader</a></span> reader;
  reader<span class="operator">.</span>setFormat(<span class="string">&quot;png&quot;</span>); <span class="comment">// same as reader.setFormat(&quot;PNG&quot;);</span>

</pre>
<p>You can call <a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>() for the full list of formats <a href="qimagereader.html">QImageReader</a> supports.</p>
<p><b>See also </b><a href="qimagereader.html#format">format</a>().</p>
<!-- @@@setFormat -->
<!-- $$$setGamma[overload1]$$$setGammafloat -->
<h3 class="fn" id="setGamma"><a name="setGamma"></a><span class="type">void</span> QImageReader::<span class="name">setGamma</span>(<span class="type">float</span> <i>gamma</i>)</h3>
<p>This is an image format specific function that forces images with gamma information to be gamma corrected to <i>gamma</i>. For image formats that do not support gamma correction, this value is ignored.</p>
<p>To gamma correct to a standard PC color-space, set gamma to <code>1/2.2</code>.</p>
<p>This function was introduced in Qt 5.6.</p>
<p><b>See also </b><a href="qimagereader.html#gamma">gamma</a>().</p>
<!-- @@@setGamma -->
<!-- $$$setQuality[overload1]$$$setQualityint -->
<h3 class="fn" id="setQuality"><a name="setQuality"></a><span class="type">void</span> QImageReader::<span class="name">setQuality</span>(<span class="type">int</span> <i>quality</i>)</h3>
<p>Sets the quality setting of the image format to <i>quality</i>.</p>
<p>Some image formats, in particular lossy ones, entail a tradeoff between a) visual quality of the resulting image, and b) decoding execution time. This function sets the level of that tradeoff for image formats that support it.</p>
<p>In case of scaled image reading, the quality setting may also influence the tradeoff level between visual quality and execution speed of the scaling algorithm.</p>
<p>The value range of <i>quality</i> depends on the image format. For example, the &quot;jpeg&quot; format supports a quality range from 0 (low visual quality) to 100 (high visual quality).</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qimagereader.html#quality">quality</a>() and <a href="qimagereader.html#setScaledSize">setScaledSize</a>().</p>
<!-- @@@setQuality -->
<!-- $$$setScaledClipRect[overload1]$$$setScaledClipRectconstQRect& -->
<h3 class="fn" id="setScaledClipRect"><a name="setScaledClipRect"></a><span class="type">void</span> QImageReader::<span class="name">setScaledClipRect</span>(const <span class="type"><a href="../qtcore/qrect.html">QRect</a></span> &amp;<i>rect</i>)</h3>
<p>Sets the scaled clip rect to <i>rect</i>. The scaled clip rect is the clip rect (also known as ROI, or Region Of Interest) that is applied after the image has been scaled.</p>
<p><b>See also </b><a href="qimagereader.html#scaledClipRect">scaledClipRect</a>() and <a href="qimagereader.html#setScaledSize">setScaledSize</a>().</p>
<!-- @@@setScaledClipRect -->
<!-- $$$setScaledSize[overload1]$$$setScaledSizeconstQSize& -->
<h3 class="fn" id="setScaledSize"><a name="setScaledSize"></a><span class="type">void</span> QImageReader::<span class="name">setScaledSize</span>(const <span class="type"><a href="../qtcore/qsize.html">QSize</a></span> &amp;<i>size</i>)</h3>
<p>Sets the scaled size of the image to <i>size</i>. The scaling is performed after the initial clip rect, but before the scaled clip rect is applied. The algorithm used for scaling depends on the image format. By default (i.e&#x2e;, if the image format does not support scaling), <a href="qimagereader.html">QImageReader</a> will use QImage::scale() with Qt::SmoothScaling.</p>
<p><b>See also </b><a href="qimagereader.html#scaledSize">scaledSize</a>(), <a href="qimagereader.html#setClipRect">setClipRect</a>(), and <a href="qimagereader.html#setScaledClipRect">setScaledClipRect</a>().</p>
<!-- @@@setScaledSize -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn" id="size"><a name="size"></a><span class="type"><a href="../qtcore/qsize.html">QSize</a></span> QImageReader::<span class="name">size</span>() const</h3>
<p>Returns the size of the image, without actually reading the image contents.</p>
<p>If the image format does not support this feature, this function returns an invalid size. Qt's built-in image handlers all support this feature, but custom image format plugins are not required to do so.</p>
<p><b>See also </b><a href="qimageiohandler.html#ImageOption-enum">QImageIOHandler::ImageOption</a>, <a href="qimageiohandler.html#option">QImageIOHandler::option</a>(), and <a href="qimageiohandler.html#supportsOption">QImageIOHandler::supportsOption</a>().</p>
<!-- @@@size -->
<!-- $$$subType[overload1]$$$subType -->
<h3 class="fn" id="subType"><a name="subType"></a><span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> QImageReader::<span class="name">subType</span>() const</h3>
<p>Returns the subtype of the image.</p>
<p>This function was introduced in Qt 5.4.</p>
<!-- @@@subType -->
<!-- $$$supportedImageFormats[overload1]$$$supportedImageFormats -->
<h3 class="fn" id="supportedImageFormats"><a name="supportedImageFormats"></a><code>[static] </code><span class="type">QList</span>&lt;<span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span>&gt; QImageReader::<span class="name">supportedImageFormats</span>()</h3>
<p>Returns the list of image formats supported by <a href="qimagereader.html">QImageReader</a>.</p>
<p>By default, Qt can read the following formats:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Format</th><th >MIME type</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td >BMP</td><td >image/bmp</td><td >Windows Bitmap</td></tr>
<tr valign="top" class="even"><td >GIF</td><td >image/gif</td><td >Graphic Interchange Format (optional)</td></tr>
<tr valign="top" class="odd"><td >JPG</td><td >image/jpeg</td><td >Joint Photographic Experts Group</td></tr>
<tr valign="top" class="even"><td >PNG</td><td >image/png</td><td >Portable Network Graphics</td></tr>
<tr valign="top" class="odd"><td >PBM</td><td >image/x-portable-bitmap</td><td >Portable Bitmap</td></tr>
<tr valign="top" class="even"><td >PGM</td><td >image/x-portable-graymap</td><td >Portable Graymap</td></tr>
<tr valign="top" class="odd"><td >PPM</td><td >image/x-portable-pixmap</td><td >Portable Pixmap</td></tr>
<tr valign="top" class="even"><td >XBM</td><td >image/x-xbitmap</td><td >X11 Bitmap</td></tr>
<tr valign="top" class="odd"><td >XPM</td><td >image/x-xpixmap</td><td >X11 Pixmap</td></tr>
<tr valign="top" class="even"><td >SVG</td><td >image/svg+xml</td><td >Scalable Vector Graphics</td></tr>
</table></div>
<p>Reading and writing SVG files is supported through the <a href="../qtsvg/qtsvg-index.html">Qt SVG</a> module. The <a href="../qtimageformats/qtimageformats-index.html">Qt Image Formats</a> module provides support for additional image formats.</p>
<p>Note that the <a href="../qtwidgets/qapplication.html">QApplication</a> instance must be created before this function is called.</p>
<p><b>See also </b><a href="qimagereader.html#setFormat">setFormat</a>(), <a href="qimagewriter.html#supportedImageFormats">QImageWriter::supportedImageFormats</a>(), and <a href="qimageioplugin.html">QImageIOPlugin</a>.</p>
<!-- @@@supportedImageFormats -->
<!-- $$$supportedMimeTypes[overload1]$$$supportedMimeTypes -->
<h3 class="fn" id="supportedMimeTypes"><a name="supportedMimeTypes"></a><code>[static] </code><span class="type">QList</span>&lt;<span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span>&gt; QImageReader::<span class="name">supportedMimeTypes</span>()</h3>
<p>Returns the list of MIME types supported by <a href="qimagereader.html">QImageReader</a>.</p>
<p>Note that the <a href="../qtwidgets/qapplication.html">QApplication</a> instance must be created before this function is called.</p>
<p><b>See also </b><a href="qimagereader.html#supportedImageFormats">supportedImageFormats</a>() and <a href="qimagewriter.html#supportedMimeTypes">QImageWriter::supportedMimeTypes</a>().</p>
<!-- @@@supportedMimeTypes -->
<!-- $$$supportedSubTypes[overload1]$$$supportedSubTypes -->
<h3 class="fn" id="supportedSubTypes"><a name="supportedSubTypes"></a><span class="type">QList</span>&lt;<span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span>&gt; QImageReader::<span class="name">supportedSubTypes</span>() const</h3>
<p>Returns the list of subtypes supported by an image.</p>
<p>This function was introduced in Qt 5.4.</p>
<!-- @@@supportedSubTypes -->
<!-- $$$supportsAnimation[overload1]$$$supportsAnimation -->
<h3 class="fn" id="supportsAnimation"><a name="supportsAnimation"></a><span class="type">bool</span> QImageReader::<span class="name">supportsAnimation</span>() const</h3>
<p>Returns <code>true</code> if the image format supports animation; otherwise, false is returned.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qmovie.html#supportedFormats">QMovie::supportedFormats</a>().</p>
<!-- @@@supportsAnimation -->
<!-- $$$supportsOption[overload1]$$$supportsOptionQImageIOHandler::ImageOption -->
<h3 class="fn" id="supportsOption"><a name="supportsOption"></a><span class="type">bool</span> QImageReader::<span class="name">supportsOption</span>(<span class="type"><a href="qimageiohandler.html#ImageOption-enum">QImageIOHandler::ImageOption</a></span> <i>option</i>) const</h3>
<p>Returns <code>true</code> if the reader supports <i>option</i>; otherwise returns false.</p>
<p>Different image formats support different options. Call this function to determine whether a certain option is supported by the current format. For example, the PNG format allows you to embed text into the image's metadata (see <a href="qimagereader.html#text">text</a>()), and the BMP format allows you to determine the image's size without loading the whole image into memory (see <a href="qimagereader.html#size">size</a>()).</p>
<pre class="cpp">

  <span class="type"><a href="qimagereader.html#QImageReader">QImageReader</a></span> reader(<span class="string">&quot;:/image.png&quot;</span>);
  <span class="keyword">if</span> (reader<span class="operator">.</span>supportsOption(<span class="type"><a href="qimageiohandler.html">QImageIOHandler</a></span><span class="operator">::</span>Size))
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Size:&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> reader<span class="operator">.</span>size();

</pre>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qimagewriter.html#supportsOption">QImageWriter::supportsOption</a>().</p>
<!-- @@@supportsOption -->
<!-- $$$text[overload1]$$$textconstQString& -->
<h3 class="fn" id="text"><a name="text"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QImageReader::<span class="name">text</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>key</i>) const</h3>
<p>Returns the image text associated with <i>key</i>.</p>
<p>Support for this option is implemented through <a href="qimageiohandler.html#ImageOption-enum">QImageIOHandler::Description</a>.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qimagereader.html#textKeys">textKeys</a>() and <a href="qimagewriter.html#setText">QImageWriter::setText</a>().</p>
<!-- @@@text -->
<!-- $$$textKeys[overload1]$$$textKeys -->
<h3 class="fn" id="textKeys"><a name="textKeys"></a><span class="type"><a href="../qtcore/qstringlist.html">QStringList</a></span> QImageReader::<span class="name">textKeys</span>() const</h3>
<p>Returns the text keys for this image. You can use these keys with <a href="qimagereader.html#text">text</a>() to list the image text for a certain key.</p>
<p>Support for this option is implemented through <a href="qimageiohandler.html#ImageOption-enum">QImageIOHandler::Description</a>.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qimagereader.html#text">text</a>(), <a href="qimagewriter.html#setText">QImageWriter::setText</a>(), and <a href="qimage.html#textKeys">QImage::textKeys</a>().</p>
<!-- @@@textKeys -->
<!-- $$$transformation[overload1]$$$transformation -->
<h3 class="fn" id="transformation"><a name="transformation"></a><span class="type"><a href="qimageiohandler.html#Transformation-enum">QImageIOHandler::Transformations</a></span> QImageReader::<span class="name">transformation</span>() const</h3>
<p>Returns the transformation metadata of the image, including image orientation. If the format does not support transformation metadata, <a href="qimageiohandler.html#Transformation-enum">QImageIOHandler::TransformationNone</a> is returned.</p>
<p>This function was introduced in Qt 5.5.</p>
<p><b>See also </b><a href="qimagereader.html#setAutoTransform">setAutoTransform</a>() and <a href="qimagereader.html#autoTransform">autoTransform</a>().</p>
<!-- @@@transformation -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
